package concurrent;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @program: study2025
 * @description: 线程池相关
 * @author: liuChangFu
 * @data: 2025-02-10 18:54
 **/
public class Excutors {

    static ThreadPoolExecutor executors = new ThreadPoolExecutor(5, 10, 2,
            TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new ThreadPoolExecutor.CallerRunsPolicy());

    public static void main(String[] args) {
        for (int i = 0; i < 25; i++) {
            int finalI = i;
            executors.execute(()->{
                System.out.println(Thread.currentThread().getName()+"--"+ finalI);
            });
//            executors.submit(()->{})
        }
        executors.shutdown();
    }
}
